package com.njbw.user.db;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * 数据归档场景枚举
 */
@Getter
public enum BackUpDataSceneEnum {

    USER_FORWARD("user_forward", "用户数据归档正向，由 sys_user 到 sys_user_backup"),
    USER_BACKWARD("user_backward", "用户数据归档逆向，由 sys_user_backup 到 sys_user");

    private final String code;

    private final String desc;

    BackUpDataSceneEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据 code 获取场景枚举
     */
    public static BackUpDataSceneEnum getByCode(String codeVal) {
        if (StringUtils.isBlank(codeVal)) return null;
        for (BackUpDataSceneEnum backUpDataSceneEnum : BackUpDataSceneEnum.values()) {
            if (backUpDataSceneEnum.code.equals(codeVal)) {
                return backUpDataSceneEnum;
            }
        }
        return null;
    }
}
